home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: warning: possibly incorrect assignment
- Date: 9 Jan 1996 09:56 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <9JAN199609561850@erich.triumf.ca>
- References: <Pine.OSF.3.91.960109091920.6447A-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <Pine.OSF.3.91.960109091920.6447A-100000@io.UWinnipeg.ca>, Bill Simpson <wsimpson@uwinnipeg.ca> writes...
- >I get the above warning when I compile code using the following
- >function. It flags the **** line.
- ..
- >**** while(fp=fopen(file_name,"r"))
- ..
- >How can I write this code so the compiler does not issue this warning?
- >Please don't suggest I just tell the compiler to shut up. In general
- >the warnings are useful. I do not want to just ignore the warning either.
-
- This is warning you of a possible common error - the compiler expects you to
- have a comparison (==) rather than an assignment (=) in the while(...). Since
- typing "=" instead of "==" is a common error, the compiler issues the warning.
- You can silence the warning either by using an explicit comparison:
- while((fp = fopen(...)) != NULL)
- or by enclosing the assignment in extra parenthesis:
- while((fp = fopen(...)))
-
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
-
-